<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>栏目管理</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__ADMIN__/style/bootstrap.css" rel="stylesheet">
    <link href="__ADMIN__/style/font-awesome.css" rel="stylesheet">
    <link href="__ADMIN__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__ADMIN__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__ADMIN__/style/demo.css" rel="stylesheet">
    <link href="__ADMIN__/style/typicons.css" rel="stylesheet">
    <link href="__ADMIN__/style/animate.css" rel="stylesheet">

</head>
<body>
<!-- 头部 -->

{include file="/public/head" /}
<!-- /头部 -->

<div class="main-container container-fluid">
    <div class="page-container">
        <!-- Page Sidebar -->

        {include file="/public/left" /}
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <a href="#">系统</a>
                    </li>
                    <li>
                        <a href="#">栏目管理</a>
                    </li>
                    <li class="active">添加栏目</li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->

            <!-- Page Body -->
            <div class="page-body">

                <div class="row">
                    <div class="col-lg-12 col-sm-12 col-xs-12">
                        <div class="widget">
                            <div class="widget-header bordered-bottom bordered-blue">
                                <span class="widget-caption">编辑栏目</span>
                            </div>
                            <div class="widget-body">
                                <div id="horizontal-form">
                                    <form class="form-horizontal" role="form" action="" method="post">
                                        <div class="form-group">
                                            <label for="username"
                                                   class="col-sm-2 control-label no-padding-right">栏目上级</label>
                                            <div class="col-sm-6">
                                                <select name="pid" id="pid">
                                                    <option value="0" >顶级栏目</option>
                                                    {volist name='cateres' id='cate'}
                                                    <option value="{$cate.id}">
                                                        {if condition="$cate.level != 0"}
                                                        |
                                                        {/if}
                                                        <?php echo str_repeat('---',$cate['level']);?>{$cate.name}
                                                    </option>
                                                    {/volist}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="username"
                                                   class="col-sm-2 control-label no-padding-right">栏目名称</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="name" placeholder="" name="name"
                                                       required="" type="text" style="width: 300px">
                                            </div>
                                            <p class="help-block col-sm-4 red">* 必填</p>
                                        </div>
                                        <div class="form-group">
                                            <label for="username"
                                                   class="col-sm-2 control-label no-padding-right">栏目类型</label>
                                            <div class="col-sm-6">
                                                <div class="radio">
                                                    <label>
                                                        <input name="type" class='type' checked="checked" type="radio" value="1">
                                                        <span class="text">列表栏目 </span>
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input name="type" class='type' type="radio" value="2">
                                                        <span class="text">单页栏目 </span>
                                                    </label>
                                                </div>
                                            </div>

                                            <p class="help-block col-sm-4 red">* 必填</p>
                                        </div>
                                        <div class="form-group">
                                            <label for="username"
                                                   class="col-sm-2 control-label no-padding-right">栏目关键字</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="keyword" placeholder="" name="keyword"
                                                       required="" type="text" style="width: 300px">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="username"
                                                   class="col-sm-2 control-label no-padding-right">栏目描述</label>
                                            <div class="col-sm-6">
                                                <textarea name="description" id="description" cols="100" rows="20"></textarea>
                                                <!--<input class="form-control" id="username" placeholder="" name="name"
                                                       required="" type="text" style="width: 300px">-->
                                            </div>
                                        </div>
                                        <!-- <div class="form-group">
                                             <label for="group_id" class="col-sm-2 control-label no-padding-right">用户角色</label>
                                             <div class="col-sm-6">
                                                 <select name="group_id" style="width: 100%;">
                                                                                         <option selected="selected" value="8">测试</option>
                                                                                     </select>
                                             </div>
                                         </div>  -->
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <button type="button" id='submit' class="btn btn-default">提交</button>
                                                <span class="message" style="color:red;font-weight: bold; margin-left: 10px;display:none;"></span>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
    </div>
</div>

<!--Basic Scripts-->
<script src="__ADMIN__/style/jquery_002.js"></script>
<script src="__ADMIN__/style/bootstrap.js"></script>
<script src="__ADMIN__/style/jquery.js"></script>
<!--Beyond Scripts-->
<script src="__ADMIN__/style/beyond.js"></script>
<script>
    jQuery('#submit').click(function(){
        var $pid = $("#pid option:selected").val();
        var $name = $('#name').val();
        var $type = $("input[name='type']:checked").val();
//        var $type = $("form input:radio:checked").val();
        var $keyword = $('#keyword').val();
        var $description = $('#description').val();
        $.ajax({
            data:{
                'pid':$pid,
                'name':$name,
                'type':$type,
                'keyword':$keyword,
                'description':$description
            },
            url: "{:url('cate/add')}",
            type: 'post',
            success: function(data){
                if(data.status == 0){
                    $('.message').css('display','inline-block').html(data.error_message);
                    $('.message').fadeOut(2000);
                }else{
                    $('.message').css('display','inline-block').html(data.message);
                    setTimeout(function(){
                        window.location = (data.url);
                    },500);

                }
            }
        })
    })
</script>

</body>
</html>